@extends('admin.layout')
@section('title', $title)
@section('content')


<div class="content-wrapper" style="min-height: 916px;">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            订单管理
            
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="#">Tables</a></li>
            <li class="active">Data tables</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">订单列表</h3>
                    </div><!-- /.box-header -->
                    <div class="box-body"><!-- box-body-->

                        <!-- 搜索框开始 -->
                        <form action="{{ url('/admin/order/manage') }}">
                            <div class="row">
                                <div class="col-md-1">
                                    <div class="form-group">
                                        <select name="num" class="form-control">
                                            <option
                                            @if(!empty($request['num']) && $request['num'] == 10)
                                                selected="selected"
                                            @endif
                                            >10</option>
                                            <option
                                            @if(!empty($request['num']) && $request['num'] == 25)
                                                selected="selected"
                                            @endif
                                            >25</option>
                                            <option
                                            @if(!empty($request['num']) && $request['num'] == 50)
                                                selected="selected"
                                            @endif
                                            >50</option>
                                            <option
                                            @if(!empty($request['num']) && $request['num'] == 100)
                                                selected="selected"
                                            @endif
                                            >100</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-md-2 col-md-offset-9">
                                    <div class="input-group">
                                        <input value="{{ $request['keywords'] or '' }}" name="keywords" type="text" class="form-control">
                                        <span class="input-group-btn">
                                            <button class="btn btn-info btn-flat">搜索</button>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </form>
                        <!-- 搜索框结束 -->

                        <div id="example2_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
                            <div class="row">
                                <div class="col-sm-6">
                                    <!-- 此处预留  -->
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-12">
                                    <table id="example2" class="table table-bordered table-hover dataTable" role="grid" aria-describedby="example2_info">
                                        <thead>
                                            <tr role="row">
                                                <th rowspan="1" colspan="1">订单ID</th>
                                                <th rowspan="1" colspan="1">订单编号</th>
                                                <th rowspan="1" colspan="1">用户名称</th>
                                                <th rowspan="1" colspan="1">商品名称</th>
                                                <th rowspan="1" colspan="1">商品图片</th>                                        
                                                <th rowspan="1" colspan="1">商品单价</th>
                                                <th rowspan="1" colspan="1">应付价格</th>
                                                <th rowspan="1" colspan="1">订单状态</th>
                                                <th rowspan="1" colspan="1">订单操作</th>
                                            </tr>
                                        </thead>
                                    <!-- 内容显示遍历开始 -->
                                    
                                       
                                    @foreach($data as $v)   
                                        <tbody>   
                                            <tr role="row" class="odd">
                                                <td class="sorting_1">{{$v -> id}}</td>
                                                <td>{{$v -> orders_id}}</td>
                                                <td>{{$v -> user_name}}</td>
                                                <td>{{$v -> category_name}}/{{$v -> goods_name}}</td>
                                                <td><img width="100" src="/uploads/goods/{{ $v -> goods_picture }}"></td>                                               
                                                <td>{{$v -> goods_price}}</td>
                                                <td>{{$v -> orders_price}}</td>
                                                <td>

                                                    @if($v -> orders_pay == 0)
                                                        未付款
                                                        
                                                    @elseif($v -> orders_pay == 1)
                                                        已付款
                                                    
                                                    @endif

                                                    &nbsp;&nbsp;
                                                    @if($v -> orders_status == 0)
                                                        未发货
                                                        
                                                    @elseif($v -> orders_status == 1)
                                                        已发货
                                                    
                                                    @endif
                                                </td>
                                                <td>
                                                <!-- manage 管理控制 -->
                                                    <form action="{{ url('/admin/manage/edit/') }}/{{ $v -> id }}/edit" method="get">
                                                        <button>编辑</button>
                                                    </form>
                                                    <form action="{{ url('/admin/order/manage') }}/{{ $v -> id }}/out" method="get"><button>移除</button>
                                                   
                                                    </form>
                                                </td>
                                                                                               
                                                
                                                                                  
                                            </tr>
                                        </tbody> 
                                    @endforeach   
                                       
                                    

                                    <!--  内容遍历结束-->

                                        <tfoot>
                                            <tr>    
                                                <th rowspan="1" colspan="1">加粗行数</th>
                                              
                                            </tr>
                                        </tfoot>
                                    </table>
                                </div>
                            </div>                                                
                        </div>
                    </div><!-- /.box-body -->
                </div><!-- /.box -->                    
            </div><!-- /.col -->
        </div><!-- /.row -->
    </section><!-- /.content -->
</div>

<script type="text/javascript">
    window.onload = function()
    {
        //隐藏警告消息
        setInterval(function()
        {
            $('#jg').fadeOut(1000);
        }, 3000);

        $('.roders_status').on('click', function()
        {
            //获取当前对象
            var t = $(this);

            //获取id
            var id = $(this).parent().find('.ids').html();
            $.ajax({
                type:"POST",
                url:"{{ url('/admin/order/ajaxOrders_Status') }}",
                data:{id:id},
                success:function(data)
                {
                    if(data == 2)
                    {
                        alert('修改失败');
                    }else if(data == 0)
                    {
                        t.html('');
                    }else if(data == 1)
                    {
                        t.html('<button class="btn btn-default btn-sm">启用</button>');
                    }
                },
                error:function()
                {
                    alert('异常');
                }
            });
        });
</script>



@endsection